package com.geek.busness.handler;

import com.geek.busness.config.ConfigLoader;
import com.geek.busness.view.Config;
import com.geek.monitor.event.HookEvent;
import com.geek.monitor.event.HookKeyboardEvent;
import com.geek.monitor.handler.KeyboardEventHandler;
import com.geek.ui.FrameUpdater;
import lombok.extern.slf4j.Slf4j;

/**
 * 业务键盘监听处理器
 */
@Slf4j
public class MyKeyboardEventHandler extends KeyboardEventHandler {

	@Override
	public void handle(HookEvent event) {
		log.debug("键盘输入："+event.getCode());
		Config config = ConfigLoader.load();
		if(event.getCode() == config.getCurKeyCode()){
			if(!config.isStarted()){
				log.debug("开启鼠标连点");
				config.setStarted(true);
			}else {
				log.debug("关闭鼠标连点");
				config.setStarted(false);
			}

			//渲染页面
			FrameUpdater.updateWindow();
		}
	}

}
